﻿using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Revit.Async;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MVVM_Revit_Demo.RevitAsyncDemo
{
    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
    [Journaling(JournalingMode.UsingCommandData)]
    public class RevitAsyncCommand : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            ////Register MyExternalEventHandler ahead of time
            //SomeEvent = ExternalEvent.Create(new MyExternalEventHandler());
            //var window = new MyWindow();
            ////Show modeless window
            //window.Show();

            RevitTask.Initialize(commandData.Application);

            RevitAsyncView revitAsyncView = new RevitAsyncView();
            RevitAsyncViewModel revitAsyncViewModel = new RevitAsyncViewModel();

            revitAsyncView.DataContext = revitAsyncViewModel;
            revitAsyncView.Show();


            return Result.Succeeded;




        }
    }
}
